<?php echo $header; ?>

<?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>

<div class="box">
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1><img src="view/image/payment.png" alt="" /> <?php echo $heading_title; ?></h1>
    <div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a></div>
  </div>
  <div class="content">
    <div id="tabs" class="htabs"><a tab="#tab-general"><?php echo $tab_general; ?></a>
      <?php if ($giftcard_id) { ?>
        <a tab="#tab-history"><?php echo $tab_giftcard_history; ?></a>
      <?php } ?>
    </div>
    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
      <div id="tab-general" class="vtabs_page1">
        <table class="form">
          <tr>
            <td><?php echo $entry_order_id; ?></td>
            <td><input type="text" name="order_id" value="<?php echo $order_id; ?>" />
              <?php if ($error_order_id) { ?>
              <span class="error"><?php echo $error_order_id; ?></span>
              <?php } ?></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_code; ?></td>
            <td><input type="text" name="code" value="<?php echo $code; ?>" readonly="readonly" style="color: #999999;"/>
              <?php if ($error_code) { ?>
              <span class="error"><?php echo $error_code; ?></span>
              <?php } ?></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_from_name; ?></td>
            <td><input type="text" name="from_name" value="<?php echo $from_name; ?>" size="80" />
              <?php if ($error_from_name) { ?>
              <span class="error"><?php echo $error_from_name; ?></span>
              <?php } ?></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_from_email; ?></td>
            <td><input type="text" name="from_email" value="<?php echo $from_email; ?>" size="80" />
              <?php if ($error_from_email) { ?>
              <span class="error"><?php echo $error_from_email; ?></span>
              <?php } ?></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_to_name; ?></td>
            <td><input type="text" name="to_name" value="<?php echo $to_name; ?>" size="80" />
              <?php if ($error_to_name) { ?>
              <span class="error"><?php echo $error_to_name; ?></span>
              <?php } ?></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_to_email; ?></td>
            <td><input type="text" name="to_email" value="<?php echo $to_email; ?>" size="80" />
              <?php if ($error_to_email) { ?>
              <span class="error"><?php echo $error_to_email; ?></span>
              <?php } ?></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_message; ?></td>
            <td><textarea name="message" cols="80" rows="5"><?php echo $message; ?></textarea></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_amount; ?></td>
            <td><input type="text" name="amount" value="<?php echo $amount; ?>" />
              <?php if ($error_amount) { ?>
              <span class="error"><?php echo $error_amount; ?></span>
              <?php } ?></td>
          </tr>
          <tr style="display: none;">
            <td><?php echo $entry_theme; ?></td>
            <td><select name="giftcard_theme_id">
                <?php foreach ($giftcard_themes as $giftcard_theme) { ?>
                <?php if ($giftcard_theme['giftcard_theme_id'] == $giftcard_theme_id) { ?>
                <option value="<?php echo $giftcard_theme['giftcard_theme_id']; ?>" selected="selected"><?php echo $giftcard_theme['name']; ?></option>
                <?php } else { ?>
                <option value="<?php echo $giftcard_theme['giftcard_theme_id']; ?>"><?php echo $giftcard_theme['name']; ?></option>
                <?php } ?>
                <?php } ?>
              </select></td>
          </tr>
          <tr>
            <td><?php echo $entry_status; ?></td>
            <td><select name="status">
                <?php if ($status) { ?>
                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                <option value="0"><?php echo $text_disabled; ?></option>
                <?php } else { ?>
                <option value="1"><?php echo $text_enabled; ?></option>
                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                <?php } ?>
              </select></td>
          </tr>
          <tr>
            <td><span style="font-weight:bold; color:#003A88;" >Send gift card email to customer</span></td>
            <td><input type="checkbox" name="send_giftcard_email" value="1" checked="checked" />
            </td>
          </tr>
        </table>
      </div>
      <?php if ($giftcard_id) { ?>
        <div id="tab-history" class="vtabs_page1">
          <div id="history"></div>         
        </div>
      <?php } ?>
    </form>
  </div>
</div>

<?php if ($giftcard_id) { ?>
  <script type="text/javascript"><!--
    var url = 'index.php?route=sale/giftcard/history&giftcard_id=<?php echo $giftcard_id; ?>&token=<?php echo $token; ?>';
    $('#history .pagination a').live('click', function() {
        $('#history').load(this.href);
        
        return false;
    });			
    
    $('#history').load(url);
  //--></script>
<?php } ?>

<script type="text/javascript"><!--
  $.tabs('#tabs a'); 
//--></script>  
<?php echo $footer; ?>